function [f1,f2,setime,manufacturetime,z] = ManufactureCost(chrome,m_no,DELIVERPlate,availableMachine,Vcut,LENGTHPlate,Setup,Setdown)
% chrome��Ⱦɫ�����
% m_no:���и�ӹ��İ������
% LENGTHPlate�������ĵ��и��
% DELIVERPlate����ĵĽ�����
% DELIVERDelayCost�����ڽ����ɱ�
% INVENTORYCost�����ɱ�
% COSTPlate����ĵĳɱ�
% STARTCost����������ɱ�
% W���и���ĵ�λ�и�ɱ�[Wcd Wcf]
% availableMachine��ÿ�������и������������[2 3]���������ͣ���һ������̨���ڶ�������̨
% Vcut���и��ٶ�

% f1������깤ʱ��
% f2���ܵ�����

    seqence = chrome(1,1:m_no);
    machineDis = chrome(1,m_no+1:end);
    z=zeros(1,m_no);
    [f1,setime,manufacturetime] = TimeCost(chrome,m_no,availableMachine,Vcut,LENGTHPlate,Setup,Setdown);%manufacturetime�����˰�ĵĿ�ʼ�ӹ�ʱ��ͽ����ӹ�ʱ��
    

    for i=1:m_no
        if (DELIVERPlate(1,chrome(i))-setime(4,i))<0
            z(1,i)=setime(4,i)-DELIVERPlate(1,chrome(i));
        else
        end
    end
    f2=sum(z);
 %����ǰ/�ӳٳɱ�
  for i=1:m_no
        if (setime(4,i)-DELIVERPlate(1,chrome(i)))>T1
           delaytime(1,i)=(DELIVERPlate(1,chrome(i))-setime(4,i))
           w(1,i)=delaytime(1,i)/DELIVERPlate(1,chrome(i))
          delay(1,i)= delaytime(1,i)*w(1,i)
          delay_cost=sum(delay,2)
        elseif (setime(4,i)-DELIVERPlate(1,chrome(i)))<T2
           advancetime(1,i)= DELIVERPlate(1,chrome(i))-setime(4,i)
           g(1,i)=abs(advancetime(1,i))/DELIVERPlate(1,chrome(i))
           advance(1,i)=advancetime(1,i)*g(1,i)
            advance_cost=sum(advance,2)
        elseif  T2<(setime(4,i)-DELIVERPlate(1,chrome(i)))<T1
            punctualtime(1,i)= DELIVERPlate(1,chrome(i))-setime(4,i)
             punctualtime(1,i)==0
        end
       f2=delay_cost +advance_cost
%     plateCost = COSTPlate;
%     startCost = STARTCost;    
%     pre_cost = 0; 
%     for i = 1:m_no
%         pre_cost = pre_cost + plateCost(i) + startCost(i);
%     end
%     
%     deliverTime = DELIVERPlate;
%     deliverDelayCost = DELIVERDelayCost;
%     inventoryCost = INVENTORYCost;
%     
%     delay_cost = 0;
%     inventory_cost = 0;6
%     delay_num = 0;
%     for j = 1:m_no
%         Index = find(j == seqence);
%         finishCutTime = manufacturetime(2,Index);
%         
%         if (finishCutTime > deliverTime(j))
%             delay_cost = delay_cost + (finishCutTime - deliverTime(j))*deliverDelayCost(j);
%             delay_num = delay_num + 1;
%         else
%             inventory_cost = inventory_cost + (deliverTime(j) - finishCutTime)*inventoryCost(j);
%         end
%     end
%        
%     cut_cost = 0;    
%     cutLength = LENGTHPlate;
%     for i = 1:m_no
%         machineType = machineDis(i);
%         cut_cost = cut_cost + W(machineType)*cutLength(seqence(i));
%     end
%     
%     f2 = pre_cost + delay_cost + inventory_cost + cut_cost;
end